package com.xius.utils;

import cn.hutool.core.lang.Validator;
import com.xius.common.ValidataConst;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName CheckFormUtil
 * @Description TODO
 * @Author 谭庆伟
 * @Date 2020/5/28 10:42
 * @Version 1.0
 **/
public class CheckFormUtil {
    public static void login(HttpServletRequest request){
        Validator.validateNotEmpty(request.getParameter("name"),"用户名不能为空");
        Validator.validateNotEmpty(request.getParameter("password"),"密码不能为空");
    }

    public static void registered(HttpServletRequest request){
        Validator.validateNotEmpty(request.getParameter("name"),"用户名不能为空");
        Validator.validateGeneral(request.getParameter("name"),"用户名只能由字母下划线数字构成");
        Validator.validateNotEmpty(request.getParameter("password"),"密码不能为空");
        String roleId = request.getParameter("roleId");
        Validator.validateNotEmpty(roleId,"角色不能为空");
        Validator.validateBetween(Integer.parseInt(roleId),0,2,"无此角色");
        Validator.validateNotEmpty(request.getParameter("phone"),"电话号码不能为空");
        Validator.validateMobile(request.getParameter("phone"), ValidataConst.VALIDATEMOBILE);

    }
    public static void projectAdd(HttpServletRequest request){
        Validator.validateNotEmpty(request.getParameter("name"), "项目名称不能为空");

    }

}
